﻿namespace WinForms
{
    using Bll.Comm;
    using Bll.Company;
    using Bll.Guest;
    using Bll.Stock;
    using Bll.Supplier;
    using Bll.Systems;
    using Model.Systems;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class PublicAppliction
    {
        private static DataTable commTypedt = new DataTable();
        private static DataTable companyAccountDt = new DataTable();
        public static ConfigEnt configEnt = null;
        private static DataTable dlDt = new DataTable();
        public static FrmMains frmMain = null;
        private static DataTable gradeGradeDt = new DataTable();
        private static int pageCount = 0x12;
        private static DataTable pardt = new DataTable();
        private static DataTable supDt = new DataTable();
        private static UserEnt user = new UserEnt();
        private static DataTable userDt = new DataTable();

        public static void ReloadCommTypeDtCatch()
        {
            UserEnt loginUser = LoginUser;
            commTypedt.Clear();
            if (loginUser != null)
            {
                commTypedt = CommTypeBll.GetList("chainNum=" + loginUser.ChainNum);
            }
        }

        public static void ReloadCompanyAccountCatch()
        {
            UserEnt loginUser = LoginUser;
            companyAccountDt.Clear();
            if (loginUser != null)
            {
                companyAccountDt = CompayAccountBll.GetList("chainNum=" + loginUser.ChainNum);
            }
        }

        public static void ReloadDlDtCatch()
        {
            UserEnt loginUser = LoginUser;
            dlDt.Clear();
            if (loginUser != null)
            {
                dlDt = DigitallibraryBll.GetList("chainNum=" + loginUser.ChainNum);
            }
        }

        public static void ReloadGuestGradeCatch()
        {
            UserEnt loginUser = LoginUser;
            gradeGradeDt.Clear();
            if (loginUser != null)
            {
                gradeGradeDt = GuestGradeBll.GetList("chainNum=" + loginUser.ChainNum);
            }
        }

        public static void ReloadParDtCatch()
        {
            pardt.Clear();
            pardt = ParameterBll.GetList("");
        }

        public static void ReloadSupplierCatch()
        {
            UserEnt loginUser = LoginUser;
            if (loginUser != null)
            {
                supDt = SupplierBll.GetList("chainNum=" + loginUser.ChainNum);
            }
        }

        public static void ReloadUserDt()
        {
            UserEnt loginUser = LoginUser;
            if (loginUser != null)
            {
                userDt = UserBll.GetList("chainNum=" + loginUser.ChainNum);
            }
            foreach (DataRow row in userDt.Rows)
            {
                row["UserPass"] = "";
            }
        }

        public static DataTable CommTypeDt
        {
            get
            {
                return commTypedt;
            }
        }

        public static DataTable CompanyAccountDt
        {
            get
            {
                return companyAccountDt;
            }
        }

        public static DataTable DlDt
        {
            get
            {
                return dlDt;
            }
        }

        public static DataTable GuestGradeDt
        {
            get
            {
                return gradeGradeDt;
            }
        }

        public static UserEnt LoginUser
        {
            get
            {
                return user;
            }
            set
            {
                user = value;
            }
        }

        public static int PageCount
        {
            get
            {
                if (Screen.PrimaryScreen.WorkingArea.Height <= 770)
                {
                    return 0x11;
                }
                return 0x1c;
            }
        }

        public static DataTable ParDt
        {
            get
            {
                return pardt;
            }
        }

        public static DataTable SupplierDt
        {
            get
            {
                return supDt;
            }
        }

        public static DataTable UserDt
        {
            get
            {
                return userDt;
            }
        }
    }
}

